#include <bits/stdc++.h>
using namespace std;
const int L=1000005;
const int N=100005;
const int M=100005;
int T;
int n,m,vmax,l,mmax;
bool over[N];
int ans,ans1;
struct Node
{
    int d,v,a;
} car[N];
bool che[M];
int mac[M];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for (int i=1; i<=T; i++)
    {
        cin>>n>>m>>l>>vmax;
        for (int j=1; j<=n; j++)
        {
            cin>>car[j].d>>car[j].v>>car[j].a;
        }
        for (int j=1; j<=m; j++)
        {
            cin>>mac[j];
            mmax=max(mmax,mac[j]);
        }
        for (int j=1; j<=n; j++)
        {
            int p=(pow(vmax,2)-pow(car[j].v,2))/2/car[j].v;
            if (p<vmax)
            {
                ans++;

            }
        }
        cout<<ans<<' '<<ans1<<endl;
    }
    return 0;
}
